<?php

namespace App\Http\Controllers\Api;

use App\Http\Controllers\Controller;
use App\Http\Server\RetailRoderServer;
use Illuminate\Http\Request;

class RetailOrderController extends Controller
{
    //零售订单
    public function __construct() {
        $this->server = new RetailRoderServer();
    }

    /**
     * 添加客户
     * @param Request $request
     */
    public function addRetailOrder(Request $request){
        $id = $request->input('id');
        $customer_id = $request->input('customer_id');
        $goods_id = $request->input('goods_id');
        $pay_type = $request->input('pay_type');
        $num = $request->input('num');
        $res = $this->server->addRetailOrderServer($id,$customer_id,$goods_id,$pay_type,$num);
        return JsonResponseService::success($res['data'],$res['msg'],$res['status']);
    }

    /**
     * 获取客户列表
     */
    public function getRetailOrderList(Request $request){
        // 获取查询条件
        $params = $request->only(['customer_id', 'goods_id','start_time','end_time']);
        $per_page = $request->input('per_page');
        $res = $this->server->getRetailOrderListServer($params,$per_page);
        return JsonResponseService::success($res['data'],$res['msg'],$res['status']);
    }

    public function getRetailOrderInfo(Request $request){
        $id = $request->input('id');
        $res = $this->server->getRetailOrderInfoServer($id);
        return JsonResponseService::success($res['data'],$res['msg'],$res['status']);
    }
}
